package views
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	
	import maps.Map;
	import maps.Tile;
	
	import views.components.CountDown;
	import views.components.GameBoard;
	import views.components.Square;
	
	[Embed(source="assets/assets.swf", symbol="VGame")]
	public class VGame extends Sprite
	{
		
		public function VGame()
		{
			super();
			
			init();
		}
		
		private function init():void
		{
			var countDown:CountDown = new CountDown();
			addAtCenter(countDown);
			countDown.addEventListener("CountEnd", onGameStart, false, 0, true);
			
		}
		
		private function onGameStart(e:Event):void
		{
			var gameboard:GameBoard = new GameBoard();
			addAtCenter(gameboard);
		}
		
		private function addAtCenter(obj:DisplayObject):void
		{
			obj.x = this.width / 2 - obj.width / 2;
			obj.y = this.height / 2 - obj.height / 2;
			this.addChild(obj);
		}
		
		private function onClick(e:MouseEvent):void
		{
//			if(e.target is Square)
//			{
//				var s:Square = e.target as Square;
//				var tileV:Vector.<Tile> = map.getSameType(s.tile);
//				for(var i:int = 0; i < tileV.length; i++)
//				{
//					tileV[i].type = -1;
//					this.removeChild(tileV[i].target);
//				}
//			}
		}
	}
}